const { Schema, model } = require("mongoose");

const RoleModel = new Schema({
  role: {
    type: String,
    required: true
  },
  roleAllow: {
    type: [{ type: Schema.Types.ObjectId, ref: "Resource" }],
    required: true //123123123
  },
  inherits: {
    type: [{ String }]
  }
});

const ResourceModel = new Schema({
  code: {
    type: String,
    required: true
  },
  name: {
    type: String,
    required: true
  },
  source: {
    type: String,
    required: true
  }
});

const Role = model("Role", RoleModel);
const Resource = model("Resource", ResourceModel);

module.exports = {
  Role,
  Resource
};
